﻿<%@ WebHandler Language="C#" Class="getSubCategory" %>

using System;
using System.Web;
using System.Data;

using AMCBO;
using AMCOBJ;

public class getSubCategory : IHttpHandler {

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        //context.Response.Write("Hello World");
        if (!string.IsNullOrEmpty(context.Request.QueryString["cateid"]))
        {
            string output = string.Empty;
            settings prodSettings = new settings();
            settingsObj objSettings = new settingsObj();
            objSettings.CateID = Convert.ToInt32(context.Request.QueryString["cateid"]);
            DataTable dt = new DataTable();
            dt = prodSettings.getSubCate(objSettings);
            if (dt.Rows.Count > 0)
            {
                output = "[";
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    output += "{\"id\":\"" + dt.Rows[i]["id"] +
                        "\",\"subcate\":\"" + dt.Rows[i]["subcate"] +
                        "\"},";
                }
                if (output[output.Length - 1] == ',')
                {
                    output = output.Substring(0, output.Length - 1);
                }
                output += "]";

                context.Response.Write(output);
            }
            else
            {
                context.Response.Write("n");
            }
        }
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}